<nz-modal
  [nzFooter]="null"
  [nzWidth]="1000"
  [(nzVisible)]="isAppointSnVisible"
  nzTitle="选择SN"
  (nzOnCancel)="handleCancel()">
  <ng-container *nzModalContent>
    <div class="common-search-wrap p-b-10">
      <div class="common-search-forms">
        <div class="common-form-item">
          <label class="common-search-label">库位</label>
          <div class="common-search-conrol">
            <nz-select
              nzShowSearch
              nzAllowClear
              nzPlaceHolder="请选择库位"
              [(ngModel)]="searchParams.libraryId">
              <nz-option
                *ngFor="let option of locationOptions"
                [nzLabel]="option.name"
                [nzValue]="option.id"
              ></nz-option>
            </nz-select>
          </div>
        </div>

        <div class="common-form-item">
          <label class="common-search-label">SN码</label>
          <div class="common-search-conrol">
            <input
              nz-input
              placeholder="请输入SN码"
              [(ngModel)]="searchParams.snCode"
            />
          </div>
        </div>

        <div class="common-form-item">
          <div class="common-search-conrol">
            <button
              nz-button
              nzType="primary"
              [nzLoading]="tableParams.loading"
              (click)="searchData()"
            >查询</button>

            <button
              nz-button
              nzType="default"
              class="m-l-10"
              (click)="resetData()"
            >重置</button>
          </div>
        </div>
      </div>
    </div>

    <div class="goods-opera-wrap p-b-20">
      <div>
        <button
          nz-button
          nzType="primary"
          class="mbtn-green"
          (click)="subSelectChecked()">
          选中已勾选 {{ setOfCheckedId.size }}
        </button>

        <button
          *ngIf="!isHideClear"
          nz-button
          nzType="primary"
          nzDanger
          [disabled]="!setOfCheckedId.size"
          class="m-l-8"
          (click)="clearSelectChecked()">
          清空已选 {{ setOfCheckedId.size }}
        </button>
      </div>

      <ul class="goods-info-ul">
        <li>
          <span class="li-label">商品编码</span>
          <span>{{ goodsInfoData.goodsCode || '-' }}</span>
        </li>
        <li>
          <span class="li-label">仓库</span>
          <span>
            {{ filterText(warehouseOptions, goodsInfoData.whId) }}
          </span>
        </li>
        <li>
          <span class="li-label">品质</span>
          <span>
            {{ goodsInfoData.quality === 0 ? '不良品' : (goodsInfoData.quality === 1 ? '良品' : '-') }}
          </span>
        </li>
        <li>
          <span class="li-label">预计出库数量</span>
          <span>{{ goodsInfoData.number || '0' }}</span>
        </li>
      </ul>
    </div>

    <div class="table-wrap">
      <nz-table
        #basicTable
        nzSize="small"
        nzShowSizeChanger
        nzShowQuickJumper
        nzBordered
        [nzFrontPagination]="false"
        [nzLoadingDelay]="100"
        [nzLoading]="tableParams.loading"
        [nzData]="tableParams.tableData"
        [nzPageSizeOptions]="[5, 10, 20, 50, 100]"
        [nzTotal]="tableParams.total"
        [nzPageIndex]="tableParams.page"
        [nzPageSize]="tableParams.pageSize"
        [nzShowTotal]="totalTemplate"
        (nzPageIndexChange)="onPageIndexChange($event)"
        (nzPageSizeChange)="onPageSizeChange($event)"
        (nzCurrentPageDataChange)="onCurrentPageDataChange($event)"
      >
        <thead>
          <tr>
            <th
              nzWidth="50px"
              [(nzChecked)]="checked"
              [nzIndeterminate]="indeterminate"
              (nzCheckedChange)="onAllChecked($event)"
            ></th>
            <th nzAlign="center">状态</th>
            <th nzAlign="center">库位</th>
            <th nzAlign="center">SN码</th>
            <th nzAlign="center">入库时间</th>
          </tr>
        </thead>

        <tbody>
          <tr *ngFor="let data of basicTable.data; let index = index;">
            <td
              [nzDisabled]="data.state !== 0"
              [nzChecked]="setOfCheckedId.has(data.id)"
              (nzCheckedChange)="onItemChecked(data.id, $event)"
            ></td>
            <!-- 状态 -->
            <td nzAlign="center">
              <span [ngStyle]="{'color': data.state | storeSncodeStatus: 'color'}">
                {{ data.state | storeSncodeStatus: 'label' }}
              </span>
            </td>
            <!-- 库位 -->
            <td nzAlign="center">
              {{ filterText(locationOptions, data.libraryId) }}
            </td>
            <!-- SN码 -->
            <td nzAlign="center">{{ data.code || '-' }}</td>
            <!-- 入库时间 -->
            <td nzAlign="center">{{ data.warehousingTime || '-' }}</td>
          </tr>
        </tbody>
      </nz-table>

      <!-- 分页template -->
      <ng-template #totalTemplate let-total>共有 {{ total }} 条</ng-template>
    </div>
  </ng-container>
</nz-modal>